package com.util;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class RandomDemo {
    /**
     * 获取[1-100]
     */
    @Test
    public void test01(){
        Map<Integer, Integer> map = new HashMap();
        Random rand = new Random();
        for(int i=0; i<10000; i++) {
            int i1 = rand.nextInt(5)+ 1;//1-5的随机数
            map.put(i1, map.get(i1) == null ? 1 :(map.get(i1)+1));
        }
        System.out.println(map);
        //随机产生26个字母
        Character c = (char) (rand.nextInt(26)+'a');
        System.out.println(c);
    }
}
